@extends('admin.app')

@section('breadcrumb')
  <div class="bg-light lter b-b wrapper-md">
    <ol class="breadcrumb bg-light lter m-n no-padder">
      <li><a href="{{admin_action('HomeController@index')}}">主页</a></li>
      <li><a href="{{admin_action('Web\ProfitsController@index')}}">分润规则</a></li>
      <li class="active">新增分润规则</li>
    </ol>
  </div>
@endsection

@section('content')
  <div class="panel panel-default">
  <div class="panel-heading font-bold">
    分润规则信息
  </div>
  <div class="panel-body">
    <form class="form-horizontal form-validation" action="{{ admin_action('Web\ProfitsController@store') }}" method="post">
      {{ csrf_field() }}
      <div class="form-group">
        <label class="col-lg-2 control-label">模板名称*</label>
        <div class="col-lg-10">
          <input type="text" class="form-control" name="name" value="{{old('name')}}" placeholder="请输入模板名称" data-rule-required="true" data-rule-maxlength="100">
        </div>
      </div>
      <div class="line line-dashed b-b line-lg"></div>
      @foreach ($stages as $stage)
        <div class="form-group">
          <label class="col-lg-2 control-label">{{$stage->name}}*</label>
          <div class="col-sm-12">
            <div class="form-group">
              <label class="col-lg-2 control-label"></label>
              <div  class="col-sm-7">
                @foreach ($roles as $role)
                  <div class="form-group">
                    <label class="col-lg-2 text-right">{{$role->name}} </label>
                    <div class="col-sm-3">
                      <input type="text" class="form-control" name="{{$stage->code.'-'.$role->code}}" value="0" {{in_array($role->code,$arr[$stage->code])?'':'readonly'}}/>
                    </div>
                    <div class="col-sm-3 ">%</div>
                  </div>
                @endforeach
              </div>
            </div>
          </div>
        </div>
      @endforeach
      <div class="line line-dashed b-b line-lg"></div>
      <div class="form-group">
        <label class="col-lg-2 control-label">分润方式*</label>
        <div class="col-lg-10">
          <select name="mode" class="form-control select2">
            <option value>-----请选择分润方式-----</option>
            @foreach ($modes as $mode)
              <option value="{{$mode->code}}" {{old('mode')==$mode->code?'selected':''}}>{{$mode->name}}</option>
            @endforeach
          </select>        </div>
      </div>
      <div class="line line-dashed b-b line-lg"></div>
      <div class="form-group">
        <div class="col-lg-4 col-lg-offset-2">
          <a href="{{ admin_action('Web\ProfitsController@index') }}" class="btn btn-default">返&nbsp;回</a>
          <button type="submit" class="btn btn-primary">保&nbsp;存</button>
        </div>
      </div>
    </form>
  </div>
</div>
@endsection

